* Uses code from miinc.ado
* Based on Scott 2013 http://2013.isiproceedings.org/Files/STS075-P3-S.pdf




program define getaicw, rclass

	tempname ilog gdeff
	
	matrix `ilog' = e(ilog)
	
	mata: ilog = select(st_matrix("`ilog'"), abs(sign(st_matrix("`ilog'"))))
	
	mata: st_matrix("`ilog'", ilog[1, cols(ilog)])
	
	matrix `gdeff' = trace(invsym(e(V_srs))*e(V))
	
	scalar myaicw = -2*`ilog'[1,1]*(e(N)/e(N_pop))+2*`gdeff'[1,1]
	display myaicw
	return scalar AICW = myaicw
end



